<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
   <title>FishVideo信息管理平台</title>
   <link href="http://libs.baidu.com/bootstrap/3.0.3/css/bootstrap.min.css" rel="stylesheet">
   <script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
   <script src="http://libs.baidu.com/bootstrap/3.0.3/js/bootstrap.min.js"></script>
  <style>
 .table th{
		text-align:center;
	}
	.table td{
		text-align:center;
	}
	#left{
		width:20%;
		float:left;
	}
	#content{
		width:80%;
		margin-left:20%;
	}
</style>
</head>
<body>
<?php require_once("control_daohang.php");?>
	<div class="container" id=left>
	<?php require_once("menu.html");?>
	</div>
<div id="content">
	<table class="table">
		<tr><th>序号</th><th>评论内容</th><th>评论时间</th><th>用户</th><th>影片</th><th>操作</th></tr>
			<?php
				require_once("../utils/db.php");
				$conn=connect();
			//所有type信息的输出
			if(isset($_GET['del'])){//如果删除
				$sql="delete from fishvideo_comments where yjl_cid='{$_GET['del']}';";
				//echo $sql;
				if(!mysql_query($sql,$conn)){
					echo "<script>alert('删除失败!');</script>";
				}
			}
			$sql="select * from fishvideo_comments";
			if(isset($_POST['search'])){//查询
				$sql.=" where yjl_content like '%{$_POST['videoname']}%'
				or yjl_uid = (select yjl_uid from fishvideo_users where yjl_uname like '%{$_POST['videoname']}%') or yjl_vid=(select yjl_vid from fishvideo_video where yjl_videoname like '%{$_POST['videoname']}%') ";
			}
			//echo $sql;
			$result=mysql_query($sql,$conn);
			$sumnumber=mysql_num_rows($result);
			//分页
			if(!isset($_GET['page'])){//如果没有
					$page=0;
				}else{
					$page=$_GET['page'];
				}
				$perpage=10;//每页10个
				$pagenumberq=$page*10;
				$sql.=" limit {$pagenumberq},{$perpage}";
				//echo $sql;
				$ym=($pagenumberq+$perpage);
				if($ym>($sumnumber)) $ym=($sumnumber);
			$result=mysql_query($sql,$conn);
			for($ct=($pagenumberq+1);$ct<=$ym;$ct++){
				$row=mysql_fetch_array($result);
				echo "<tr><td>{$ct}</td>";
				echo "<td>{$row['yjl_content']}</td>";
				echo "<td>{$row['yjl_cdate']}</td>";
				//用户名
				$sql="select yjl_uname from fishvideo_users where yjl_uid='{$row['yjl_uid']}'";
				$res=mysql_query($sql);
				$res=mysql_fetch_array($res);
				echo "<td>{$res[0]}</td>";

				//影片名
				$sql="select yjl_videoname from fishvideo_video where yjl_vid='{$row['yjl_vid']}'";
				$res=mysql_query($sql);
				$res=mysql_fetch_array($res);
				echo "<td>{$res[0]}</td>";

				echo "<td><a onclick=\"confirm('确定要删除吗')?
			location.href='control_comments.php?del={$row['yjl_cid']}':''\"
				href=\"javascript:;\"> 删除</a></td>";
				}
				mysql_close($conn);
			?>
			  <div id="dispage">
		<span>
		 <?php
			if($sumnumber%$perpage==0)
			$sumpage=(int)($sumnumber/$perpage);
			else $sumpage=(int)(($sumnumber/$perpage)+1);
				$now =$page+1;
		    echo "共有{$sumnumber}条数据，当前第({$now}/{$sumpage})页";
		?>
		</span>
		<span>
		<?php
		echo "<a href='control_user.php?page=0'>首页</a> ";
		if($page!=0){
		$now = $page-1;
		echo "<a href='control_user.php?page={$now}'>上一页</a> ";
		}
		if($page!=($sumpage-1)){
			$now = $page+1;
		echo "<a href='control_user.php?page={$now}'>下一页</a> ";
		}
		$now=$sumpage-1;
		echo "<a href='control_user.php?page={$now}'>尾页</a>";
		?>
		</span>
	</div>		
	</tr>
		</table>
	</div>
</div>
</body>
</html>